﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows;

namespace Faust.Andrew.MTG.Utilities
{
    public class RarityToBrush : IValueConverter
    {
        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            string rarity = value as string;
            if (String.IsNullOrEmpty(rarity))
            {
                rarity = "Common";
            }

            SolidColorBrush brush = new SolidColorBrush(Colors.Black);

            switch (rarity)
            {
                case "Uncommon":
                    brush = new SolidColorBrush(Colors.Silver);
                    break;
                case "Rare":
                    brush = new SolidColorBrush(Colors.Goldenrod);
                    break;
                case "Mythic Rare":
                    brush = new SolidColorBrush(Colors.Peru);
                    break;
                default:
                    //Default to common color of black.
                    break;
            }

            return brush;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return "Rare";
        }

        #endregion
    }
}